package ar.com.fiuba.ElectronicCircuitAnalyst.domain.specs;

import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Component;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.common.Specification;

public class ComponentLeadsQtySpecification implements Specification<Component> {

	/**
	 * Components must have at least 1 input and 1 output. 
	 * Also, Components cannot have more outputs than inputs,
	 * unless it is a Demultiplexer (Demux). 
	 * See {@link ComponentLeadsQtyDemuxSpecification}.
	 */
	public Boolean isSatisfiedBy(Component component) {
		int inputs = component.getInputLeads().size();
		int outputs = component.getOutputLeads().size();
		
		return inputs >= outputs && inputs > 0 && outputs > 0; 
	}

}
